package io.renren.modules.mybog.service.impl;

import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.mybog.dao.FriendDao;
import io.renren.modules.mybog.entity.FriendEntity;
import io.renren.modules.mybog.service.FriendService;
import org.springframework.util.StringUtils;


@Service("friendService")
public class FriendServiceImpl extends ServiceImpl<FriendDao, FriendEntity> implements FriendService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<FriendEntity> wrapper = new QueryWrapper<>();
        Object key = params.get("key");
        if (!StringUtils.isEmpty(key)) {
            wrapper.eq("site_name",key);
        }
        IPage<FriendEntity> page = this.page(
                new Query<FriendEntity>().getPage(params),
              wrapper
        );

        return new PageUtils(page);
    }

    @Override
    public List<FriendEntity> ListStatus() {
        QueryWrapper<FriendEntity> friendQueryWrapper=new QueryWrapper<>();
        friendQueryWrapper.eq("status",1);
        List<FriendEntity> list = list(friendQueryWrapper);
        return list;
    }
}